<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>会员积分管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
			var type = $("#imsType").val();
			
			if(!(type == null || type =='') ){
				$("#imsIndustryType").val(type);
				
			}
			
			
			$("#name").focus();
			$('#validDays').val('${couponConfig.validDays}');
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/momarketing/couponConfig/">优惠券类型列表</a></li>
		<li class="active"><a href="${ctx}/momarketing/couponConfig/form?id=${couponConfig.id}">添加优惠券</a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="couponConfig" action="${ctx}/momarketing/couponConfig/save" method="post" class="form-horizontal" enctype="multipart/form-data">
		<form:hidden path="id"/>
		<form:hidden path="user.id"/>
		<input type="hidden" value="${couponConfig.imsIndustryType }" id="imsType"/>
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">优惠券名称:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="15" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">消息关键词:</label>
			<div class="controls">
				<form:input path="keywords" htmlEscape="false" maxlength="11" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">核销增加会员积分:</label>
			<div class="controls">
				<input name="pMemberScore" class="required number" type="text" htmlEscape="false" value="<fmt:formatNumber value='${couponConfig.memberScore/1000}' pattern='###.###'  minFractionDigits='3'/>">
				<label style="color:grey"><span class="alert">（元）精确到小数点后三位</span></label>
				<%-- <form:input path="memberScore" htmlEscape="false"  class="required"/>
				<label style="color:grey"><span class="alert">积分以“<span style="color:red;">厘</span>”为单位</span></label> --%>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">是否允许重复:</label>
			<div class="controls">
				<input type="radio" name="repeats" value="1" <c:if test="${empty couponConfig.repeats or couponConfig.repeats eq true }">  checked="checked" </c:if> /> 是   <input type="radio" name="repeats" value="0" <c:if test="${couponConfig.repeats eq false }">  checked="checked" </c:if> /> 否
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">允许最多获取数量:</label>
			<div class="controls">
				<form:input path="repeatCount" htmlEscape="false" maxlength="3" class="required"/>  <span class="alert">0:表示不限制,大于表示最多允许获取的数量</span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">优惠券有效天数:</label>
			<div class="controls">
				<select name="validDays" id="validDays">
					<% for(int i=1;i<31;i++) {%>
					<option value="<%=i%>" ><%=i %>天</option>
					<%} %>
				</select>
			</div>
		</div>
		
		
		
			<div class="control-group">
			<label class="control-label">优惠券类型:</label>
			<div class="controls">
				<select name="imsIndustryType" id="imsIndustryType">
				<option value="默认类型">默认类型</option>
					<c:forEach items="${dictList}" var="dict">
					<option value="${dict.label }">${dict.label }</option>
					
					
					</c:forEach>
					
					
					
				</select>
			</div>
		</div>
		
		<!-- 
		
			<div class="control-group">
				<label class="control-label">有效果时间:</label>
				<div class="controls">
					
						<script src="${ctxStatic}/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
						<input id="startTime" name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
							value="<fmt:formatDate value="${couponConfig.startTime}" pattern="yyyy-MM-dd"/>"
							onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>  至
						<input id="endTime" name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
							value="<fmt:formatDate value="${couponConfig.endTime}" pattern="yyyy-MM-dd"/>"
							onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
				</div>
			</div>
		 -->
		
		<div class="control-group">
			<label class="control-label">优惠券标题:</label>
			<div class="controls">
				<form:input path="qrcodeTitle" htmlEscape="false"   /> <span class="alert"> 返回二维信图片的标题</span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">优惠券描述:</label>
			<div class="controls">
				<form:textarea path="qrcodeDesc" htmlEscape="false" rows="3" cols="20" maxlength="1000"  />  <span class="alert"> 返回二维信图片的描述</span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">优惠券展示图片:</label>
			<div class="controls">
				<c:if test="${couponConfig.showPic ne '' }">
					<div class="control"><img src="${ctxUser }/score/${couponConfig.showPic }" style="width:300px;height:100px"/></div>
				</c:if>
				<div class="control">
					<input type="file" name="ShowPicfile" htmlEscape="false"   />    <span class="alert">建议尺寸：128像素 * 128像素 </span>      
				</div>
			</div>
		</div>
		
		
		<div class="control-group">
			<label class="control-label">描述:</label>
			<div class="controls">
				<form:textarea id="remarks" htmlEscape="true" path="remarks" rows="4" class="input-xlarge required"/>
   				 <tags:ckeditor replace="remarks" uploadPath="/project/pics" />
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="momarketing:couponConfig:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
